GBML manual / Queues

queue_clear

Removes every item from target, leaving it empty (queue_length(target) becomes 0, queue_empty(target) becomes true). target's own declared capacity is unchanged - it can be filled again afterward.

Syntax

queue_clear(target)

Arguments

NameType
targetqueue

Returns

Nothing.

Description

Removes every item from target, leaving it empty (queue_length(target) becomes 0, queue_empty(target) becomes true). target's own declared capacity is unchanged, so it can be filled again afterward.

Useful for a fresh start - clearing a spawn queue when the player enters a new room, say, rather than popping items one at a time.

Example

/// @type {queue<int>}
/// @capacity 4
var turn_order = [1, 2, 3];
queue_clear(turn_order);
var waiting = queue_length(turn_order); // 0
A real capture - the queue and its length before clearing, 3 items waitingA real capture - the queue and its length before clearing, 3 items waiting
A real capture - the queue and its length before clearing, 3 items waiting
The same queue after queue_clear(turn_order) - empty, and queue_length back to 0The same queue after queue_clear(turn_order) - empty, and queue_length back to 0
The same queue after queueclear(turnorder) - empty, and queue_length back to 0

On the GBA

The deque's clear() - O(n) in how many items target held (each one's destructor runs), identical to stack_clear/list_clear.

See also: queue_pushqueue_popqueue_lengthqueue_emptyData containers